package top.houry.springboot.jvm.test;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class OOMObject {
    public byte[] place = new byte[64 * 1024];

    public static void fillHeap(int num) throws InterruptedException {
        List<OOMObject> list = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            Thread.sleep(50);
            list.add(new OOMObject());
        }

        System.gc();
    }

    public static void main(String[] args) throws InterruptedException {
        TimeUnit.SECONDS.sleep(10);
        fillHeap(1000);
    }

}
